package leetcode.weekly.week318;

//Solution1Test
public class Solution1 {

	public int[] applyOperations(int[] nums) {
		for (int i = 0; i < nums.length - 1; i++) {
			if (nums[i] == nums[i + 1]) {
				nums[i] <<= 1;
				nums[i + 1] = 0;
			}
		}
		int p = 0;
		for (int i = 0; i < nums.length; i++) {
			if (nums[i] != 0) {
				nums[p++] = nums[i];
			}
		}
		for (int i = p; i < nums.length; i++) {
			nums[i] = 0;
		}
		return nums;
	}

}
